<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1" charset="UTF-8">
    <title>com.drake.engine.swipeback</title>
<link href="../../../../images/logo-icon.svg" rel="icon" type="image/svg"><script>var pathToRoot = "../../";</script><script type="text/javascript" src="../../scripts/sourceset_dependencies.js" async="async"></script><link href="../../styles/style.css" rel="Stylesheet"><link href="../../styles/logo-styles.css" rel="Stylesheet"><link href="../../styles/jetbrains-mono.css" rel="Stylesheet"><link href="../../styles/main.css" rel="Stylesheet"><script type="text/javascript" src="../../scripts/clipboard.js" async="async"></script><script type="text/javascript" src="../../scripts/navigation-loader.js" async="async"></script><script type="text/javascript" src="../../scripts/platform-content-handler.js" async="async"></script><script type="text/javascript" src="../../scripts/main.js" async="async"></script>  </head>
  <body>
    <div id="container">
      <div id="leftColumn"><a href="../../index.html">
          <div id="logo"></div>
        </a>
        <div id="paneSearch"></div>
        <div id="sideMenu"></div>
      </div>
      <div id="main">
        <div id="leftToggler"><span class="icon-toggler"></span></div>
<script type="text/javascript" src="../../scripts/main.js"></script>        <div class="main-content" id="content" pageIds="Engine::com.drake.engine.swipeback////PointingToDeclaration//-1683276876">
          <div class="navigation-wrapper" id="navigation-wrapper">
            <div class="breadcrumbs"><a href="../../index.html">Engine</a>/<a href="index.html">com.drake.engine.swipeback</a></div>
            <div class="pull-right d-flex">
              <div id="searchBar"></div>
            </div>
          </div>
          <div class="cover ">
            <h1 class="cover"><span>Package com.</span><wbr></wbr><span>drake.</span><wbr></wbr><span>engine.</span><wbr></wbr><span>swipeback</span></h1>
          </div>
          <div class="tabbedcontent">
            <div class="tabs-section" tabs-section="tabs-section"><button class="section-tab" data-active="" data-togglable="Types">Types</button></div>
            <div class="tabs-section-body">
              <h2 class="">Types</h2>
              <div class="table" data-togglable="Types"><a data-name="-1199662270%2FClasslikes%2F-1683276876" anchor-label="DecelerateAnimator" id="-1199662270%2FClasslikes%2F-1683276876" data-filterable-set=":engine:dokkaHtml/release"></a>
                <div class="table-row" data-filterable-current=":engine:dokkaHtml/release" data-filterable-set=":engine:dokkaHtml/release">
                  <div class="main-subrow keyValue ">
                    <div class=""><span class="inline-flex"><a href="-decelerate-animator/index.html">DecelerateAnimator</a><span class="anchor-wrapper"><span class="anchor-icon" pointing-to="-1199662270%2FClasslikes%2F-1683276876"></span>
                          <div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
                        </span></span></div>
                    <div>
                      <div class="title"><div class="divergent-group" data-filterable-current=":engine:dokkaHtml/release" data-filterable-set=":engine:dokkaHtml/release"><div class="with-platform-tags"><span class="pull-right"></span></div>

  <div>
    <div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-depenent-content" data-active="" data-togglable=":engine:dokkaHtml/release"><div class="symbol monospace">class <a href="-decelerate-animator/index.html">DecelerateAnimator</a> <span>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-overloads/index.html">JvmOverloads</a>() </span>constructor(context: <a href="https://developer.android.com/reference/kotlin/android/content/Context.html">Context</a>, mBounceCoeff: <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html">Float</a>, isBouncing: <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>) : <a href="https://developer.android.com/reference/kotlin/android/animation/ValueAnimator.html">ValueAnimator</a><span class="top-right-position"><span class="copy-icon"></span><div class="copy-popup-wrapper popup-to-left"><span class="copy-popup-icon"></span><span>Content copied to clipboard</span></div></span></div></div></div>
  </div>
<a data-name="-1199662270%2FClasslikes%2F-1683276876" anchor-label="DecelerateAnimator" id="-1199662270%2FClasslikes%2F-1683276876" data-filterable-set=":engine:dokkaHtml/release"></a><div class="brief "><a data-name="-1199662270%2FClasslikes%2F-1683276876" anchor-label="DecelerateAnimator" id="-1199662270%2FClasslikes%2F-1683276876" data-filterable-set=":engine:dokkaHtml/release"></a>减速动画，默认启用回弹效果。</div></div>
</div>
                    </div>
                  </div>
                </div>
<a data-name="-549121824%2FClasslikes%2F-1683276876" anchor-label="ShadowView" id="-549121824%2FClasslikes%2F-1683276876" data-filterable-set=":engine:dokkaHtml/release"></a>
                <div class="table-row" data-filterable-current=":engine:dokkaHtml/release" data-filterable-set=":engine:dokkaHtml/release">
                  <div class="main-subrow keyValue ">
                    <div class=""><span class="inline-flex"><a href="-shadow-view/index.html">ShadowView</a><span class="anchor-wrapper"><span class="anchor-icon" pointing-to="-549121824%2FClasslikes%2F-1683276876"></span>
                          <div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
                        </span></span></div>
                    <div>
                      <div class="title"><div class="divergent-group" data-filterable-current=":engine:dokkaHtml/release" data-filterable-set=":engine:dokkaHtml/release"><div class="with-platform-tags"><span class="pull-right"></span></div>

  <div>
    <div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-depenent-content" data-active="" data-togglable=":engine:dokkaHtml/release"><div class="symbol monospace">class <a href="-shadow-view/index.html">ShadowView</a> <span>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-overloads/index.html">JvmOverloads</a>() </span>constructor(context: <a href="https://developer.android.com/reference/kotlin/android/content/Context.html">Context</a>, showShadowBar: <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>, showBackground: <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a>) : <a href="https://developer.android.com/reference/kotlin/android/view/View.html">View</a><span class="top-right-position"><span class="copy-icon"></span><div class="copy-popup-wrapper popup-to-left"><span class="copy-popup-icon"></span><span>Content copied to clipboard</span></div></span></div></div></div>
  </div>
</div>
</div>
                    </div>
                  </div>
                </div>
<a data-name="-910488498%2FClasslikes%2F-1683276876" anchor-label="SwipeBackHelper" id="-910488498%2FClasslikes%2F-1683276876" data-filterable-set=":engine:dokkaHtml/release"></a>
                <div class="table-row" data-filterable-current=":engine:dokkaHtml/release" data-filterable-set=":engine:dokkaHtml/release">
                  <div class="main-subrow keyValue ">
                    <div class=""><span class="inline-flex"><a href="-swipe-back-helper/index.html">SwipeBackHelper</a><span class="anchor-wrapper"><span class="anchor-icon" pointing-to="-910488498%2FClasslikes%2F-1683276876"></span>
                          <div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
                        </span></span></div>
                    <div>
                      <div class="title"><div class="divergent-group" data-filterable-current=":engine:dokkaHtml/release" data-filterable-set=":engine:dokkaHtml/release"><div class="with-platform-tags"><span class="pull-right"></span></div>

  <div>
    <div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-depenent-content" data-active="" data-togglable=":engine:dokkaHtml/release"><div class="symbol monospace"><div class="block"><div class="block">@<a href="https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi.html">RequiresApi</a>(<span>api = <span class="breakable-word">19</span></span><wbr></wbr>)</div></div>class <a href="-swipe-back-helper/index.html">SwipeBackHelper</a>(activity: <a href="https://developer.android.com/reference/kotlin/android/app/Activity.html">Activity</a>)<span class="top-right-position"><span class="copy-icon"></span><div class="copy-popup-wrapper popup-to-left"><span class="copy-popup-icon"></span><span>Content copied to clipboard</span></div></span></div></div></div>
  </div>
<a data-name="-910488498%2FClasslikes%2F-1683276876" anchor-label="SwipeBackHelper" id="-910488498%2FClasslikes%2F-1683276876" data-filterable-set=":engine:dokkaHtml/release"></a><div class="brief "><a data-name="-910488498%2FClasslikes%2F-1683276876" anchor-label="SwipeBackHelper" id="-910488498%2FClasslikes%2F-1683276876" data-filterable-set=":engine:dokkaHtml/release"></a>Activity侧滑返回支持，状态栏透明思路：<ol><li><p class="paragraph">在构造方法中设置透明状态栏，利用反射将窗口转为不透明，同时监听布局变化以解决adjustResize失效问题</p></li></ol><ol><li><p class="paragraph">在Activity的dispatchTouchEvent方法中拦截触摸事件，满足条件则进行侧滑</p></li></ol><ol><li><p class="paragraph">侧滑事件前，利用反射将窗口转为透明；侧滑取消后，利用反射将窗口转为不透明</p></li></ol>使用说明：<ol><li><p class="paragraph">仅支持SDK19(Android4.4)及以上</p></li></ol><ol><li><p class="paragraph">因状态栏透明，布局会从屏幕顶端开始绘制，Toolbar高度需自行调整</p></li></ol><ol><li><p class="paragraph">状态栏透明会导致输入法的adjustPan模式失效，建议设置为adjustResize</p></li></ol><ol><li><p class="paragraph">必须设置以下属性，否则侧滑时无法透视下层Activity</p></li></ol><item name="android:windowBackground">@android:color/transparent</item><ol><li><p class="paragraph">必须设置以下属性，否则ActionMode会插入页面顶端，且状态栏会显示黑色</p></li></ol><item name="windowActionModeOverlay">true</item><ol><li><p class="paragraph">SDK21(Android5.0)以下必须设置以下属性，否则无法通过反射将窗口转为透明</p></li></ol><item name="android:windowIsTranslucent">true</item><ol><li><p class="paragraph">侧滑时会利用反射将窗口转为透明，此时会引起下层Activity生命周期变化，留意可能因此导致的严重问题</p></li></ol>(a) onDestory -&gt; onCreat -&gt; onStart -&gt; (onResume -&gt; onPause) -&gt; onStop(b) onRestart -&gt; onStart -&gt; (onResume -&gt; onPause) -&gt; onStop<ol><li><p class="paragraph">当顶层Activity方向与下层Activity方向不一致时侧滑会失效（下层方向未锁定除外），建议关闭该层Activity侧滑功能。</p></li></ol>示例场景：视频APP的播放页面和下层页面。<ol><li><p class="paragraph">如需动态支持横竖屏切换，屏幕方向需指定为&quot;behind&quot;跟随栈底Activity方向，同时在onCreate中判断若不支持横竖屏切换，则锁定屏幕方向（避免behind失效）。</p></li></ol></div></div>
</div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="footer"><span class="go-to-top-icon"><a href="#content"></a></span><span>© 2021 Copyright</span><span class="pull-right"><span>Generated by </span><a href="https://github.com/Kotlin/dokka"><span>dokka</span><span class="padded-icon"></span></a></span></div>
      </div>
    </div>
  </body>
</html>

